/**
 * 冒泡排序
 */
const bubbleSort = (arr) => {
    const len = arr.length
    for (let i = 0; i < len - 1; i++) {
        for (let j = 0; j < len - 1- i; j++) {
            if (arr[j] > arr[j + 1]) {
                const temp = arr[j + 1]
                arr[j+1] = arr[j]
                arr[j] = temp
            }
        }
    }
    return arr
}

const arr = [7,1,6,5,3,2,8,4]
console.log(bubbleSort(arr))